'''
Created on Nov 26, 2013

@author: maxp
'''

import argparse

def main():
    parser = argparse.ArgumentParser(description='Compare the alignments found by two programs.')
    parser.add_argument('file1',type=argparse.FileType('r'))
    parser.add_argument('file2',type=argparse.FileType('r'))
    
    args = parser.parse_args()
    
    d1 = {}
    for line in args.file1:
        d1[line.split()[0]] = set(line.split()[1:])
        
    d2 = {}
    for line in args.file2:
        d2[line.split()[0]] = set(line.split()[1:])
            
    if d1==d2:
        args.file1.close()
        args.file2.close()
        print "they are the same"
        return True
    else:
        for k in d2.keys():
            if k not in d1.keys():
                print "key not in file1: ", k
            else:
                if d1[k] != d2[k]:
                    print "mismatch on key: ", k
                    print "d1[k] length = ", len(d1[k])
                    print "d2[k] length = ", len(d2[k])
                    
        for k in d1.keys():
            if k not in d2.keys():
                print "key not in file2: ", k
            else:
                if d1[k] != d2[k]:
                    print "mismatch on key: ", k
                    print "d1[k] length = ", len(d1[k])
                    print "d2[k] length = ", len(d2[k])
        args.file1.close()
        args.file2.close()
        return False
                
if __name__ == '__main__':
    main()